﻿@model dynamic

@{
    ViewBag.Title = "出区诊断";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style type="text/css">
    .zdinput {
        width: 90%;
    }
</style>
<form id="form1">
    <div class="panel panel-default" style="padding-right:10px;">
        <table class="form">
            <tr>
                <th class="formTitle">诊断时间：</th>
                <td class="formValue">
                    <input id="txt_zdsj" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:70%;" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', onpicked: function () { RefreshOrder() } })" value="@DateTime.Now.ToString("yyyy-MM-dd ")" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">出院诊断：</th>
                <td class="formValue">
                    <input id="txt_cyzddm" type="hidden" />
                    <input id="txt_cyzd" name="txt_cyzd" type="text" class="form-control required zdinput" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">辅助诊断1：</th>
                <td class="formValue">
                    <input id="txt_fzzd1dm" type="hidden" />
                    <input id="txt_fzzd1" name="txt_fzzd1" type="text" class="form-control required zdinput" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">辅助诊断2：</th>
                <td class="formValue">
                    <input id="txt_fzzd2dm" type="hidden" />
                    <input id="txt_fzzd2" name="txt_fzzd2" type="text" class="form-control required zdinput" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">辅助诊断3：</th>
                <td class="formValue">
                    <input id="txt_fzzd3dm" type="hidden" />
                    <input id="txt_fzzd3" name="txt_fzzd3" type="text" class="form-control required zdinput" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">自定义诊断：</th>
                <td class="formValue">
                    <textarea id="txt_zdyzd" name="txt_zdyzd" class="form-control zdinput" style="height: 60px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>
<script lang="javascript">
    $(function () {
        GetPatDiagnosis();
    })
    $("#txt_cyzd").zdFloatingSelector({
        zdlx: "WM",
        width: "75%",
        itemdbclickhandler: function ($this) {
            $("#txt_cyzd").val($this.attr('data-zdmc'));
            $("#txt_cyzddm").val($this.attr('data-zdCode'));
        }
    });
    $("#txt_fzzd1").zdFloatingSelector({
        zdlx: "WM",
        width: "75%",
        itemdbclickhandler: function ($this) {
            $("#txt_fzzd1").val($this.attr('data-zdmc'));
            $("#txt_fzzd1dm").val($this.attr('data-zdCode'));
        }
    });
    $("#txt_fzzd2").zdFloatingSelector({
        zdlx: "WM",
        width: "75%",
        itemdbclickhandler: function ($this) {
            $("#txt_fzzd2").val($this.attr('data-zdmc'));
            $("#txt_fzzd2dm").val($this.attr('data-zdCode'));
        }
    });
    $("#txt_fzzd3").zdFloatingSelector({
        zdlx: "WM",
        width: "75%",
        itemdbclickhandler: function ($this) {
            $("#txt_fzzd3").val($this.attr('data-zdmc'));
            $("#txt_fzzd3dm").val($this.attr('data-zdCode'));
        }
    });
    function GetPatDiagnosis() {
        $.najax({
            type: "GET",
            url: "/NurseManage/WardMaintenance/GetPatDiagnosis?r=" + Math.random(),
            data: { zyh: '@ViewBag.zyh' },
            loadingtext: "数据加载中，请稍后...",
            dataType: "json",
            success: function (zdlist) {
                $.each(zdlist, function (n, item) {
                    if (item.zdlx=="0") {
                        $("#txt_cyzd").val(item.zdmc);
                        $("#txt_cyzddm").val(item.zddm);
                    }
                    if (item.zdlx == "1") {
                        $("#txt_fzzd1").val(item.zdmc);
                        $("#txt_fzzd1dm").val(item.zddm);
                    }
                    if (item.zdlx == "2") {
                        $("#txt_fzzd2").val(item.zdmc);
                        $("#txt_fzzd2dm").val(item.zddm);
                    }
                    if (item.zdlx == "3") {
                        $("#txt_fzzd3").val(item.zdmc);
                        $("#txt_fzzd3dm").val(item.zddm);
                    }
                    if (item.zdlx == "9") {
                        $("#txt_zdyzd").val(item.zdmc);
                    }
                })
            }
        })
    }
    function SavaOutArea()
    {
        var zyh = '@ViewBag.zyh';
        //var cyfs = $("#sel_cqfs").val();
        //var cqsj = $("#txt_cqrq").val();
        var zdrq = $("#txt_zdsj").val();
        var zyzd = $("#txt_cyzd").val();
        var zyzddm = $("#txt_cyzddm").val();
        var fzzd1 = $("#txt_fzzd1").val();
        var fzzd1dm = $("#txt_fzzd1dm").val();
        var fzzd2 = $("#txt_fzzd2").val();
        var fzzd2dm = $("#txt_fzzd2dm").val();
        var fzzd3 = $("#txt_fzzd3").val();
        var fzzd3dm = $("#txt_fzzd3dm").val();
        var zdyzd = $("#txt_zdyzd").val();
        var patOutAreaVO = {
            zyh: zyh,
            //cyfs: cyfs,
            //cqsj: cqsj,
            zdrq: zdrq,
            zyzd: zyzd,
            zyzddm: zyzddm,
            fzzd1: fzzd1,
            fzzd1dm: fzzd1dm,
            fzzd2: fzzd2,
            fzzd2dm: fzzd2dm,
            fzzd3: fzzd3,
            fzzd3dm: fzzd3dm,
            zdyzd: zdyzd
        }
        if (zyzd == "" || zyzddm=="") {
            $.modalAlert('该患者没有出院诊断，不允许出区！', 'warning');
            return;
        }
      
        $.ajax({
            type: "POST",
            url: "/NurseManage/WardMaintenance/SavaOutPatDiagnosis",
            data: { patOutAreaVO: patOutAreaVO },
            dataType: "json",
            async:false,
            success: function (ajaxresp) {
                if (ajaxresp.state=="success") {
                    $.modalMsg('保存成功', 'success');
                }
                else {
                    $.modalAlert(ajaxresp.message, 'warning');
                }
                clearData();
            }
        });
    }

    function clearData()
    {
        //$("#sel_cqfs").val("");
        //$("#txt_cqrq").val("");
        $("txt_zdsj").val("");
        $("#txt_cyzd").val("");
        $("#txt_cyzddm").val("");
        $("#txt_fzzd1").val("");
        $("#txt_fzzd1dm").val("");
        $("#txt_fzzd2").val("");
        $("#txt_fzzd2dm").val("");
        $("#txt_fzzd3").val("");
        $("#txt_fzzd3dm").val("");
        $("#txt_zdyzd").val("");
    }
</script>